from pyspark.context import SparkContext, SparkConf
from pyspark.sql import HiveContext

sparkconf = SparkConf().setAppName("liz_pred").set("spark.ui.showConsoleProgress", "false")
sc = SparkContext(conf=sparkconf)
spark = HiveContext(sc)


import pandas as pd
import os
spark.sql("use liz")
df1 = spark.sql("select * from liz.tmp_kb_hw4")
df2 = spark.sql("select * from liz.0616_jz_home_gid_info")
df3 = spark.sql("select * from liz.0616_jz_work_gid_info")
A1 = df1.toPandas()
A2 = df2.toPandas()
A3 = df3.toPandas()
os.system('mkdir -p /home/liz/hzjz/0620')
writer = pd.ExcelWriter('/home/liz/hzjz/0618/WhatsAPP.xlsx', mode='')
A1.to_excel(writer, sheet_name='聚集地信息', header=True, index=False)
A2.to_excel(writer, sheet_name='聚集家庭地信息', header=True, index=False)
A3.to_excel(writer, sheet_name='聚集工作地信息', header=True, index=False)
writer.save()
writer.close()`